package com.mcc.app.finish.controller;

import java.util.Date;
import java.util.List;
import com.mcc.common.utils.SecurityUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.enums.BusinessType;
import com.mcc.app.finish.domain.FinishedTestAnalysis;
import com.mcc.app.finish.service.IFinishedTestAnalysisService;
import com.mcc.common.core.page.TableDataInfo;

/**
 * 成品检化验结果
 *
 * @author gxy
 * @date 2025-04-03
 */
@Api(tags = "成品检化验结果")
@RestController
@RequestMapping("/test/analysis")
public class FinishedTestAnalysisController extends BaseController {

    @Autowired
    private IFinishedTestAnalysisService finishedTestAnalysisService;

    @ApiOperation("查询成品检化验结果列表")
    @ApiOperationSupport(order = 1)
    @PreAuthorize("@ss.hasPermi('demo:analysis:list')")
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<FinishedTestAnalysis>> list(FinishedTestAnalysis finishedTestAnalysis) {
        List<FinishedTestAnalysis> list = finishedTestAnalysisService.selectFinishedTestAnalysisList(finishedTestAnalysis);
        return getDataTable(list);
    }

    @ApiOperation("查询成品检化验结果列表(分页)")
    @ApiOperationSupport(order = 2)
    @PreAuthorize("@ss.hasPermi('demo:analysis:list')")
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<FinishedTestAnalysis>> page(FinishedTestAnalysis finishedTestAnalysis) {
        startPage();
        List<FinishedTestAnalysis> list = finishedTestAnalysisService.selectFinishedTestAnalysisList(finishedTestAnalysis);
        return getDataTable(list);
    }

    @ApiOperation("获取成品检化验结果详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('demo:analysis:query')")
    @GetMapping("/get/{id}")
    public AjaxResult<FinishedTestAnalysis> getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(finishedTestAnalysisService.selectFinishedTestAnalysisById(id));
    }

    @ApiOperation("新增成品检化验结果")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('demo:analysis:add')")
    @Log(title = "成品检化验结果", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FinishedTestAnalysis finishedTestAnalysis) {
        return toAjax(finishedTestAnalysisService.insertFinishedTestAnalysis(finishedTestAnalysis));
    }

    @ApiOperation("修改成品检化验结果")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('demo:analysis:edit')")
    @Log(title = "成品检化验结果", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody FinishedTestAnalysis finishedTestAnalysis) {
        return toAjax(finishedTestAnalysisService.updateFinishedTestAnalysis(finishedTestAnalysis));
    }

    @ApiOperation("删除成品检化验结果")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('demo:analysis:remove')")
    @Log(title = "成品检化验结果", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(finishedTestAnalysisService.deleteFinishedTestAnalysisByIds(ids));
    }

    @ApiOperation("导出停机记录列表")
    @Log(title = "导出停机记录列表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FinishedTestAnalysis finishedTestAnalysis) {
        return AjaxResult.success(finishedTestAnalysisService.exportStopRecordList(finishedTestAnalysis));
    }


}
